# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=geany
pkgver=1.38
pkgrel=0
pkgdesc="fast and lightweight IDE"
url="https://www.geany.org"
arch="all"
license="GPL-2.0-or-later"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
makedepends="gtk+3.0-dev intltool perl-xml-parser vte3-dev"
replaces="geany-dev"
source="https://download.geany.org/geany-$pkgver.tar.gz
	https://download.geany.org/contrib/tags/dbus-glib-0.76.c.tags
	https://download.geany.org/contrib/tags/drupal.php.tags
	https://download.geany.org/contrib/tags/ethos-1.0.c.tags
	https://download.geany.org/contrib/tags/geany-api-0.19.c.tags
	https://download.geany.org/contrib/tags/gladeui-1.0.c.tags
	https://download.geany.org/contrib/tags/gnt.c.tags
	https://download.geany.org/contrib/tags/gtk220.c.tags
	https://download.geany.org/contrib/tags/gtkscintilla-2.0.c.tags
	https://download.geany.org/contrib/tags/gtksourceview-3.0.c.tags
	https://download.geany.org/contrib/tags/libdevhelp-2.0.c.tags
	https://download.geany.org/contrib/tags/libgdl-3.0.c.tags
	https://download.geany.org/contrib/tags/libxml-2.0.c.tags
	https://download.geany.org/contrib/tags/openjdk8-8u66-b01.java.tags
	https://download.geany.org/contrib/tags/sqlite3.c.tags
	https://download.geany.org/contrib/tags/standard.css.tags
	https://download.geany.org/contrib/tags/std.glsl.tags
	https://download.geany.org/contrib/tags/std.latex.tags
	https://download.geany.org/contrib/tags/std.vala.tags
	https://download.geany.org/contrib/tags/v4l2.c.tags
	https://download.geany.org/contrib/tags/webkit-1.0.c.tags
	https://download.geany.org/contrib/tags/wordpress.php.tags
	https://download.geany.org/contrib/tags/xfce46.c.tags
	https://download.geany.org/contrib/tags/xfce48.c.tags
	http://advamacs.com/pub/tcl.tcl.tags
	set_default_terminal.patch
"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--enable-vte \
		--enable-gtk3
	make
}

check() {
	make check
}

package() {
	sed -i 's|MimeType=text/plain;|MimeType=|' geany.desktop
	sed -i 's|Sh=|Sh=APKBUILD;|' data/filetype_extensions.conf
	make DESTDIR="$pkgdir" install

	# install the tags
	local _tags=
	for i in $source; do
		case $i in
		*.tags) _tags="$_tags $srcdir/${i##*/}";;
		esac
	done
	mkdir -p "$pkgdir"/usr/share/$pkgname/tags
	install -p $_tags "$pkgdir"/usr/share/$pkgname/tags/
	install -p $_tags "$pkgdir"/usr/share/$pkgname/tags
}

dev() {
	default_dev
	mv "$subpkgdir"/usr/share/geany/filedefs/*.c "$pkgdir"/usr/share/geany/filedefs/
	mv "$subpkgdir"/usr/share/geany/templates/files/*.c \
		"$pkgdir"/usr/share/geany/templates/files/
	rmdir "$subpkgdir"/usr/share/geany/templates/files \
		"$subpkgdir"/usr/share/geany/templates \
		"$subpkgdir"/usr/share/geany/filedefs \
		"$subpkgdir"/usr/share/geany \
		"$subpkgdir"/usr/share
}

sha512sums="
e7f73b138617b1af82d9a6413b4b9ab435cab89a45b869d3ec1f2865ac75afb8e2df9d7a053d5df31be90e77407566d7ee512c569f0e682a72c5acce756b8dd1  geany-1.38.tar.gz
89551143b5557a632b325cceef9c0fa56ea0f9a28d1bd7bed4dba99af5005812702bbf0519f6ce97ce77c362fa454caac8d18c168ffb4af5f91ed6a4df2995e9  dbus-glib-0.76.c.tags
9d06d993ddd3fbc6445a215e327e4d0bfb498bcf0431fff69b66b4fc2163717a313c5a876d0dcd922859f97fb8f5beb20f034dafb99b321be37282f226c76057  drupal.php.tags
1db55822822fe5f9d85ff619c6e2fb9703ed7646eefb8925f8e2f632fb9f6aecaddf1580496e0d9daa9d3d7e466febc80d73ae3955075d1dd92fc238571d5fd1  ethos-1.0.c.tags
3201f66fc6bf75d82b7c2ed0ee694d74a047771e01e81f4fc505df3fcce7389eed750aae1ad09b55b5ef0227d9a92161d32c40117917905059aa3a0fe7c14f3b  geany-api-0.19.c.tags
4b9b92fd01ea09fe093a9aa08cb7fc82fc793bc3c61551f383c713be96a85ad599f188c234f1796b85975898570cebf938c997ad8190c89d4c0f2c26a7468cf4  gladeui-1.0.c.tags
a7abfa99736ef6eb4a2bbee68e370b9913624bf432165cafc8b052b4d52b2e7b2cccebcaec8fefba773b4aaf8fa441aa1597ea03aadabc64bad7be0cb0681e35  gnt.c.tags
bb48aec2d4f6ad1d0a853760b60b5a3e26502ff42e74e182a03dd04f0d7b6b47290466f7ac497eb51f2bce5fd6f6c21ee9ac426fbb333171244a52833cee82d7  gtk220.c.tags
0b45a883663ade6c97ba52cfbebea57c0ff54d3195b2bc00209bb62e08566a16b3306399a062020a06b47c20fc210db60ca52cbe2798c4846243dd7dc52c678e  gtkscintilla-2.0.c.tags
f7f6256969b4630e6fe28052b278e2858df581bbd39a24892232c0f1aac8d5da2c009bc48a3f6b61d82625f9858e43a0cb0dc9ff7562305fb0fb9637ae8690d6  gtksourceview-3.0.c.tags
81c84b0d4290bd1031fb56c176c98276094eb0e27ae6e55376445577c46991b65fa7fff0d106d8669b2aaea84d264017ec08b145dbe45d598885c5d8f8334f22  libdevhelp-2.0.c.tags
767970487967fe2ae80ae076813116d5b3a04de3427b0c447b7f889f9b04a37747f933b86685f4e8a0be94cbb21f0d841b528511451939dc710f1f34b3d1849e  libgdl-3.0.c.tags
0cff6575b23aa5fc94efc0923c085f463c224cbb1b26f696e2be5ca1080a34be01be6a90f5ee2f7191c1bee660e2b3e50c50343cace8df8d0b2ebd3d205ad0d0  libxml-2.0.c.tags
862ff5d29e7f8dab493a5c51f070eea24307de754f6bd5c99b58f39082256428682b4eb6ec460f8bf8e5af1fe760f2c485cb3a1ab20b30a7e31f35e1c2104000  openjdk8-8u66-b01.java.tags
afa5e2e0ffc0cb6aa1462e68fcd213b8c5447718f1ac5719677217a7d60ae2b9adc26662224872f133869fa34d3c18b136c9d909f38752b32b3ecd15616588cd  sqlite3.c.tags
0c653aa84886cfd441aab37c11e8462b7540fa4b5f9d479ed09de063a23887b4b5b833a1b3296a4873931ee41b7679155cfd1a70ff535a497ebdef9e211546b0  standard.css.tags
616ede8e41dec4cb97e646c8b447a606c54de52369df11c26d94f5e508643f6eb45805030b48e432420a564effa1217e88fcbd34aa0a487d8c4823c6ddc79d40  std.glsl.tags
90e188d1a7e4da7fb6680870ba936c1ae9637a186f970c3a6e6690ed7f3555e5dca33b4b32c75d3da322e93dd911fd8b5f574201dd15f12ec58f5f163f434a09  std.latex.tags
8b2669f8ef6cfcf6e27bcb3de039e134702353754d62ef6ee7e73cd8cb8cd1d8bdbf9ab07b2fca59c7ff04e1066d8e6b0080fb9d8db573582b857ee471c8b837  std.vala.tags
2d8f30c29b589a892f86a629014ccac36a698eedfd3961d01da73adda1fcd43623451e340d74e8c85c5028d4e2d789c3268f52889bb22c671e06e780123269f5  v4l2.c.tags
9fcea2e6c652ffc351461974924eaee0c5a9d58763e5a37a82e7c20957a1d02c044abaee1834b738f733fb309c1de9f31bd15083b60809527040898e853ca1a1  webkit-1.0.c.tags
fe3f88e86a0f098a2f85df76ddd04978bb8f2bed87ea8cc7c3325ea904f5c625fb2b10757d0f8edaf9e5d483699f79f21648e444b10b7760ee72d0c244ce463f  wordpress.php.tags
822ffacbd42c72c459ccd2b44ecfb580c5c65816beaec23638d74d61a8e832c1486b902c3950a892a49b2ce5232533490653ff8bab2194f1b412f16f64c66090  xfce46.c.tags
cecd0d4c71fc163fff52c4aec48e69559e9b55f16becfbcb083a453a1e1e6c3ee0835917210511cab134995de3efbf870943313ffdd667ca089501f468fe7564  xfce48.c.tags
71012d3f6d11a7b5171c1debce928fe31776af64a4f7c36fc27946fed220b9918c0894932d54c8a2fb55611ca5a458b7f8d3ae05ee269d83e2e704f0baa6b674  tcl.tcl.tags
ab07a6d1ba4dd9d09dcaa8231476d6cd4e6ce6278bc07ed5f343e864ccf769bb136e3d220c9771081778c2c37ea3651cb67516c5385e12aa88376d6affd294e1  set_default_terminal.patch
"
